//1．修改程序清单13.1中的程序，要求提示用户输入文件名，
//并读取用户输入的信息，不使用命令行参数。

/* count.c -- using standard I/O */
#include <stdio.h>
#include <stdlib.h> //

#define SIZE 81
int main()
{
    int ch;         // place to store each character as read
    FILE *fp;       // "file pointer"
    unsigned long count = 0;
    char filename[SIZE];
    printf("Enter the name of file:");
    scanf("%s", filename);
    if ((fp = fopen(filename, "r")) == NULL)
    {
        printf("Can't open %s\n", filename);
        exit(EXIT_FAILURE);
    }
    while ((ch = getc(fp)) != EOF)
    {
        putc(ch,stdout);  // same as putchar(ch);
        count++;
    }
    fclose(fp);
    printf("File %s has %lu characters\n", filename, count);

    return 0;
}
